package file;

import java.io.File;

/*
A:判断功能
public boolean isDirectory():判断是否是目录
public boolean isFile():判断是否是文件
public boolean exists():判断是否存在
public boolean canRead():判断是否可读
public boolean canWrite():判断是否可写
public boolean isHidden():判断是否隐藏
B:案例演示
File类的判断功能
 */
public class Demo04_FileMethod {
    public static void main(String[] args) {

        //extracted();
        //extracted1();
        //extracted2();
        //extracted3();
        //extracted4();
        //extracted5();

    }

    private static void extracted5() {
        //判断是否是隐藏的文件or文件夹
        File file = new File("wzx.txt");
        System.out.println(file.isHidden());
    }

    private static void extracted4() {
        File file = new File("wzx.txt");

        //windows系统可以设置为不可写
        file.setWritable(false);
        System.out.println(file.canWrite());
    }

    private static void extracted3() {
        File file = new File("wzx.txt");

        //windows系统默认所有的文件都是可读的，这么写没有意义
        file.setReadable(false);
        System.out.println(file.canRead());
    }

    private static void extracted2() {
        //判断该文件or文件夹是否存在
        File file = new File("ccc");
        System.out.println(file.exists());
    }

    private static void extracted1() {
        //判断是否是一个文件
        File file = new File("ccc");
        System.out.println(file.isFile());
    }

    private static void extracted() {
        //判断是不是文件夹
        File dir1 = new File("ccc");
        System.out.println(dir1.isDirectory());
    }
}
